package com.whxy02.tolearn.app.config;


import com.whxy02.tolearn.app.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//拦截器
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    UserLoginInterceptor getUserLoginInterceptor(){
        return new UserLoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] cut={"/**"};
        String[] pas={"/index/**","/index*","/login/check","/login*",
                "/register/**","/register*","/admin*","/AddTest/Add.html","/js/**","/css/**","/file/**","/fonts/**","/images/**","/"};
        registry.addInterceptor(getUserLoginInterceptor()).addPathPatterns(cut).excludePathPatterns(pas);
    }
}
